#include "mytcpsocket.h"
#include <QDebug>
//自定义封装
MyTcpSocket::MyTcpSocket(QObject *parent) : QTcpSocket(parent)
{
    /*它本身会发出信号*/
    connect(this,&QTcpSocket::readyRead,this,&MyTcpSocket::recvMsg);
}

void MyTcpSocket::recvMsg()
{
    qDebug()<<"我自己的data";
    qDebug()<<this->bytesAvailable();//当前发送过来的数据有多大
    uint uiPdulen=0;
    this->read((char*)&uiPdulen,sizeof(uint));//前面4个字节的大小
    uint uiMsgLen=uiPdulen-sizeof(PDU);
    PDU* pdu=mkPdu(uiMsgLen);//产生一个新数据
    this->read((char *)pdu+sizeof (uint),uiPdulen-sizeof(uint));
    qDebug()<<pdu->uiMsgType<<(char*)pdu->caMsg;
}
